import {createRouter , createWebHashHistory, RouteRecordRaw} from 'vue-router'
import Login from '@/pages/login/index.vue'
import Layout from '@/components/layout/index.vue'
import Home from '@/pages/home/index.vue'
const routes:RouteRecordRaw[] =[
    {
        path: '/login',
        component: Login
    },
    {
        path: '/main',
        name: 'main',
        meta: {title: "main", requireAuth: true},
        component:Layout,
        redirect: '/home',
        children: [
            { 
              path: '/home',
              name: '欢迎',
              meta: {title: "欢迎", requireAuth: true},
              component: Home
            },
        ]
      },
      {
        path: '/product',
        name: 'product',
        meta: {title: "商品", requireAuth: true},
        component:Layout,
        children: [
          {
            path: '/product-add',
            name: '添加商品',
            meta: {title: "添加商品", requireAuth: true},
            component: () => import('@/pages/detail/product.vue')
          },
          { 
            path: '/product-list',
            name: '商品列表',
            meta: {title: "商品列表", requireAuth: true},
            component: () => import('@/pages/detail/list.vue')
          }
        ]
      },
      {
        path: '/user',
        name: '用户管理',
        meta: {title: "user", requireAuth: true},
        component:Layout,
        children: [
            { 
              path: '/user-userInfo',
              name: '用户管理',
              meta: {title: "用户管理", requireAuth: true},
              component: () => import('@/pages/user/userManagement.vue')
            },
            {
              path: '/user-auth',
              name: '权限管理',
              meta: {title: "权限管理", requireAuth: true},
              component: () => import('@/pages/user/auth.vue')
            }
        ]
      },
      {
        path:'/business',
        name: '商户管理',
        meta: {title: "business", requireAuth: true},
        component:Layout,
        children: [
        { 
          path: '/business-list',
          name: '商户列表',
          meta: {title: "商户列表", requireAuth: true},
          component: () => import('@/pages/business/businesslist.vue')
        },
        {
          path: '/business-analysis',
          name: '商户分析',
          meta: {title: "商户分析", requireAuth: true},
          component: () => import('@/pages/business/businessAnalysis.vue')
        }
      ]
      }
]
const router = createRouter(
    {
        history:createWebHashHistory(),
        routes
    }
)
export default router